package com.gjy.mysql.sql;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2022-12-15 14:02:54
 */
public final class QueryRule implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final int ASC_ORDER = 101;
    public static final int DESC_ORDER = 102;
    public static final int LIKE = 1;
    public static final int IN = 2;
    public static final int NOT_IN = 3;
    public static final int BETWEEN = 4;
    public static final int EQ = 5;
    public static final int NOT_EQ = 6;
    public static final int GT = 7;
    public static final int GE = 8;
    public static final int LT = 9;
    public static final int LE = 10;
    public static final int ISNULL = 11;
    public static final int IS_NOT_NULL = 12;
    public static final int IS_EMPTY = 13;
    public static final int IS_NOT_EMPTY = 14;
    public static final int AND = 201;
    public static final int OR = 202;
    private List<Rule> rules = new ArrayList<>();
    private List<QueryRule> queryRules = new ArrayList<>();
    private String prototypeName;

    private static class Rule implements Serializable {

        private static final long serialVersionUID = 1L;

        private int type; // 规则的类型
        private String prototypeName;
        private Object[] values;
        private int andOr = AND;

        public Rule(int type, String prototypeName) {
            this.type = type;
            this.prototypeName = prototypeName;
        }

        public Rule(int type, String prototypeName, Object[] values) {
            this.type = type;
            this.prototypeName = prototypeName;
            this.values = values;
        }

        public Rule setAndOr(int andOr) {
            this.andOr = andOr;
            return this;
        }

        public int getAndOr() {
            return this.andOr;
        }

        public int getType() {
            return this.type;
        }

        public Object[] getValues() {
            return this.values;
        }
    }

}
